package com.mrduan.calculator.ui.calculator.sell;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.mrduan.calculator.Config;
import com.mrduan.calculator.R;
import com.mrduan.calculator.ui.calculator.base.CalculatorBean;
import com.mrduan.calculator.ui.calculator.base.CalculatorAdapter;

import java.util.List;

/**
 * Created by snoopy on 2018/4/10.
 */

public class SellCalculatorAdapter extends CalculatorAdapter {

    public List<SellCalculatorBean> sellList;

    public SellCalculatorAdapter(Context context, List list,List<SellCalculatorBean> sellList) {
        super(context, list);
        this.sellList = sellList;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.sell_calculator_list_adapter,null);

            holder = new ViewHolder();

            holder.content = convertView.findViewById(R.id.sell_adapter_content);
            holder.type = convertView.findViewById(R.id.sell_adapter_type);
            holder.way = convertView.findViewById(R.id.sell_adapter_way);
            holder.time = convertView.findViewById(R.id.sell_adapter_time);

            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        CalculatorBean bean = (CalculatorBean) list.get(position);

        if (bean.operator.equals(Config.dengyu)) {
            holder.time.setVisibility(View.VISIBLE);
        } else {
            holder.time.setVisibility(View.GONE);
        }

        holder.time.setText("-------------------" + bean.time + "-------------------");

        holder.content.setText(bean.number);
        holder.way.setText(bean.payWay);

        return convertView;
    }

    class ViewHolder {
        TextView content,type,way,time;
    }

}
